package cn.tedu.review;

/**
 * @author: Dsi
 * @date: 2021/11/10 10:17
 * @description:该类用于复习汽车设计的综合案例
 */
public class TestCar {
        public static void main(String[] args) {
                Car c=new Car();
                Bwm b=new Bwm();
                Ben b1=new Ben();
                c.setColor("hong");
                c.stop();
                c.stat();
                System.out.println(c.getColor());

                b.stat();//重写
                b.stop();//父类继承的
                System.out.println(b.getColor());//父类找get方法
                System.out.println(b.color);//

                Car c1=new Ben();
                c1.stop();
                System.out.println(c1.getColor());

                Car c2=new Bwm();
                c2.stat();
                c2.stop();
                System.out.println(c2.getColor());
               // System.out.println(c2.color);//父类找color声明，发现是private资源，访问受限
        }


}
class Car{
        private String brand;
        private int id;
        private double price;
        private String color;

        public void stat(){
                System.out.println("父类的启动");
        }
        public void stop(){
                System.out.println("父类的停止方法");
        }
        public String getBrand() {
                return brand;
        }
        public void setBrand(String brand) {
                this.brand = brand;
        }
        public int getId() {
                return id;
        }
        public void setId(int id) {
                this.id = id;
        }
        public double getPrice() {
                return price;
        }
        public void setPrice(double price) {
                this.price = price;
        }
        public String getColor() {
                return color;
        }
        public void setColor(String color) {
                this.color = color;
        }
}
class Bwm extends Car{
        String color="黑";

        @Override
        public void stat() {
                System.out.println("子类Bwm重写之超级起步");
        }
}
class Ben extends Car{
        @Override
        public void stop() {
                System.out.println("子类ben重写之无法刹车");
        }
}